<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="js/browser.js"></script>
    <script src="js/react.development.js"></script>
    <script src="js/react-dom.development.js"></script>
</head>
<body>
    <div id="div1"></div>
    
</body>
<script type="text/babel">
    // 组件
    class Cmp1 extends React.Component{
        constructor(...args){
            super(...args);
            this.state = {
                a: this.props.a
            }
        }
        fn(){
            //this.state.a++;
            //console.log(this.state)
            this.setState({
                a:this.state.a+1
            })
        }
       
        render(){
            return (
                <div>
                    <input value='+1' type='button' onClick={this.fn.bind(this)}/>
                    {this.state.a}
                </div>
            );
        }
    }

    let root = document.getElementById('div1');

    ReactDOM.render(
        <div className='box'>
            <Cmp1 a={0}></Cmp1>
        </div>,
        root
    );


</script>
</html>